package rkw.database;

import java.util.List;
import java.util.UUID;

import rkw.database.model.AdministratorToken;
import rkw.database.model.Election;
import rkw.database.model.ElectionVoter;
import rkw.database.model.Member;
import rkw.database.model.MessageReceived;
import rkw.database.model.MessageToSend;
import rkw.database.model.Node;
import rkw.database.model.Token;
import rkw.database.model.UnsendVoterId;
import rkw.database.model.Vote;
import rkw.database.model.Voter;
import core.communication.message.Direction;
import core.communication.message.Message;

public interface DatabaseService {

	public Node getMainNode();

	public Node storeNode(Node node);

	public void deleteNode(Node node);

	public Boolean isNodeLocatorUriTaken(String ip, String port);

	public List<MessageToSend> getMessagesToSend();

	public List<MessageReceived> getMessagesReceived();

	public List<Node> getNodesForDirection(Direction direction);

	public void storeMessageToSend(Message message);

	public void saveReceivedMessage(Message message);

	public void setMessageAsHandled(Long messageToSendDatabaseId);

	public void removeMessageToSend(Long messageToSendDatabaseId);

	public Node updateNode(String targetNodeUri, Node newNode);

	public void deleteNode(String targetNodeUri);

	public Election getElection(Long electionIdentificationField);

	public void deleteElection(Election election);

	public Election storeElection(Election election);

	public Member getMemberByIdentificationField(String identificationField);

	public Voter getVoterByIdentificationField(String identificationField);

	public List<Election> getAllElections();

	public Voter getVoter(Long id);

	public void deleteVoter(Voter voter);

	public Member getMember(Long id);

	public void deleteMember(Member member);

	public Voter storeVoter(Voter voter);

	public Member storeMember(Member member);

	public AdministratorToken getAdministratorTokenByMemberAndElection(Member member, Election election);

	public AdministratorToken getAdministratorTokenByValue(String value);

	public Boolean verifyVoter(Long electionIdentificationField, String voterIdentificationField);

	public List<ElectionVoter> findVotersLike(Election election, String text);

	public boolean handleVote(UUID token, Vote vote);

	public void saveToken(Token token);

	public Election getStartedElection();

	public AdministratorToken saveAdministratorToken(AdministratorToken administratorToken);

	public List<Vote> getUnsendVotes(); 
	
	public void updateVotes(List<Vote> votes);

	public UnsendVoterId storeUnsendVoterId(UnsendVoterId unsendVoterId);

	public List<UnsendVoterId> getUnsendVoterIds();

	public void deleteUnsendVoterIds(List<UnsendVoterId> voters);

	public Token getTokenByValue(String value);

}
